/**
 * https://leetcode.cn/problems/jump-game/submissions/550474223/
 * 55. 跳跃游戏
 * medium 陈贝纯 2024.07.28
 * bfs
 */

class Solution {
public:
    bool canJump(vector<int>& nums) {
        int n=nums.size();
        int p=0;
        for(int i=0;i<n-1;++i){
            p=max(p,i+nums[i]);
            if(p==i&&nums[p]==0)
            return false;
        }
        if(p>=n-1)
        return true;
        return false;
    }
};